package com.an.threadtest.procomu;

import java.util.Map;

/**
 * @author Administrator
 * 处理请求的线程
 */
public class ProcessRequestThread extends Thread {

	private RequestContainer container;

	public ProcessRequestThread(RequestContainer container,String name) {
		super(name);
		this.container = container;
	}
	
	@Override
	public void run() {
		while (true) {
			try {
				Thread.sleep((long) (Math.random() * 1000));
				Request r = container.get();
				System.out.println("当前线程：" + getName() + " 总的线程个数---"+ Thread.activeCount() + "---,被处理的请求：" + r);
				System.out.println("当前容器：" + container.size());
				Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
				System.out.println(map.keySet().contains("main"));
				for(Thread thread : map.keySet()) {
					
					System.out.println("xiancheng 线程的名称：" + thread.getName());
				}

			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	
}
